#include <string>
#include <codecvt>
#include <locale>
#include <iostream>
// UTF-8 和 UTF-16 conversion
std::u16string utf8_to_utf16(const std::string& utf8) {
    std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
    return converter.from_bytes(utf8);
}
// UTF-16 to UTF-8 conversion
std::string utf16_to_utf8(const std::u16string& utf16) {
    std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
    return converter.to_bytes(utf16);
}
int main() {
    std::string utf8 = "Hello, 世界!";
    std::u16string utf16 = utf8_to_utf16(utf8);
    std::string back_to_utf8 = utf16_to_utf8(utf16);

    std::cout << "Original UTF-8: " << utf8 << std::endl;
    std::cout << "Converted UTF-16 to UTF-8: " << back_to_utf8 << std::endl;

    return 0;
}